<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<meta name="description" content="">
    <meta name="author" content="">    
	<meta name="keywords" content="玩精灵,财经智库">	
	<title>玩精灵后台</title>	
	<link rel="shortcut icon" href="favicon.ico" />	
	<link rel="stylesheet" type="text/css" href="css/lqcss.css">
	<link rel="stylesheet" type="text/css" href="css/lqpublic.css">
	<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
	<script type="text/javascript" src="js/lqjs.js"></script>
</head>

	<body>
		<div class="container">
		<!-- 主体部分 -->
			<div class="containermain">
				<!-- 头部 -->
				<div id="header">
					<div class="header">
						<div class="logo">
							<img class="logoimg" src="images/icologo@3x.png" alt="玩精灵">
							<h2 class="logotext">玩精灵</h2>
						</div>
						<h2 class="biaoyu">欢迎登录后台管理系统</h2>
						<div class="userdiv">
							<div class="userde">
								<img class="userimg" src="images/icologo@3x.png" />
								<span class="username">Admin</span>
								<i class="icoup"></i>
							</div>
							<!-- 账户信息 -->
							<div id="userdetils">
								<p class="usertext"><i class="userico"></i>账户:18989876567</p>
								<a class="userbtn originbtn">退出登录</a>
							</div>
						</div>
					</div>
				</div>

				<!-- 内容 -->
				<div id="main">
					
						<!-- 左侧导航 -->
						<div id="leftnav">
							<ul class="leftnav">
								<li class="navli" id="nav01" onclick="javascript:location.reload();">
									<a><i class="ico"></i><span>系统管理</span></a>
								</li>
								<li class="navli" id="nav02">
									<a><i class="ico"></i><span>管理员管理</span></a>
								</li>
								<li class="navli" id="nav03">
									<a><i class="ico"></i><span>菜单管理</span></a>
								</li>
								<li class="navli" id="nav04">
									<a><i class="ico"></i><span>用户管理</span></a>
								</li>
								<li class="navli" id="nav05">
									<a><i class="ico"></i><span>权限管理</span></a>
								</li>								
							<!-- 	<li class="navli" id="nav06">
									<a><i class="ico"></i><span>角色管理</span></a>
								</li> -->
								<li class="navli select" id="nav07">
									<a><i class="ico"></i><span>内容管理</span></a>
								</li>
								<li class="navli" id="nav08">
									<a><i class="ico"></i><span>日志管理</span></a>
								</li>
								<li class="navli" id="nav09">
									<a><i class="ico"></i><span>订单管理</span></a>
								</li>
								<li class="navli" id="nav10">
									<a><i class="ico"></i><span>留言管理</span></a>
								</li>
								<li class="navli" id="nav11">
									<a><i class="ico"></i><span>数据统计</span></a>
								</li>
								<li class="navli" id="nav12">
									<a><i class="ico"></i><span>系统配置</span></a>
								</li>
							</ul>
						</div>
						<!-- 右侧内容 -->
						<div id="rightcontent">
							<div class="rightcontent">
								<!-- 内容管理 -->
								<div class="contentmarnav">
									<ul class="conternav">
										<li id="tuwen" class="conterli liselect"  onclick="javascript:location.reload();">图文</li>
										<li id="audios" class="conterli">语音</li>
										<li id="videos" class="conterli">视频</li>
									</ul>
									<div class="searchdiv">
										<input class="searchinpu" type="text" name="" placeholder="用户名">
										<a class="originborbtn usersear">查询</a>
									</div>
								</div>

								<!-- 具体内容 -->
								<div class="conterdiv">
									<div class="conter">
										<div class="contitle">
											<div class="conleft">
												
											</div>
											<div class="conright">												
												<a class="originbtn addtuwen">新建图文</a>
											</div>
										</div>

										<!-- 列表 -->
										<div id="table02">
											<!-- <div class="tab_title">
												<span class="tabt01">内容</span>
												<span class="tabt02">更新时间</span>
												<span class="tabt03">操作</span>
											</div>
											<div class="tab_content">
												<div class="tab_li">
													<div class="tabt01">
														<img class="tab_img" src="">
														<span class="tab_name">财经大决战</span>
													</div>
													<div class="tabt02">
														<span class="gryfont">11.24</span>
													</div>
													<div class="tabt03">
														<a class="tab_del"></a>
													</div>
												</div>
												<div class="tab_li">
													<div class="tabt01">
														<img class="tab_img" src="">
														<span class="tab_name">财经大决战</span>
													</div>
													<div class="tabt02">
														<span class="gryfont">11.24</span>
													</div>
													<div class="tabt03">
														<a class="tab_del"></a>
													</div>
												</div>
											</div> -->
										</div>

										<!-- 翻页 -->
										<div class="pages">
											<a class="pre"><</a>
											<ul>
												<li class="pagesnum thispage">1</li>
												<li class="pagesnum">2</li>
												<li class="pagesnum">3</li>
											</ul>
											<a class="next">></a>

										</div>
									</div>
								</div>
							</div>
						</div>
					
					
				</div>
			</div>
			
		</div>

		<!-- 预览弹窗 -->
		<div id="previewdiv">
			<div class="guanbi">关闭</div>
			<div class="iframediv"></div>
			<!-- <iframe src="http://www.caijingwulin.com/wenzde.html?id=2c90b2dc639190ea0163b923f998000a" width="375" height="667" scrolling="no" seamless="seamless">
			  <p>您的浏览器不支持 iframe 标签。请使用Chrome，Firefox，360等浏览器</p>
			</iframe> -->
		</div>
<script type="text/javascript" src="js/jquerysession.js"></script>
<script type="text/javascript">
// 头部，导航部分
$(".username").html($.session.get("loginName"));
$(".usertext").html('<i class="userico"></i>账户:'+$.session.get("loginName")+'');

//判断登录状态
var username = $.session.get('loginName');
console.log(username);
if(username==null || username == undefined){
	//未登录
	window.location.href="login.html";
}

//退出登录
$(".userbtn").click(function(){	
	$.ajax({
		type: "post",
		url: url+"manager/outLogin",
		success: function(data){
			console.log(data);
			if(data.code=='2000'){	
				//清空缓存
				$.session.get('loginName')
				window.location.href="login.html"; 
			}else{
				window.location.href="login.html"; 
			}
		}
	})
	console.log('登出');
})

//隐藏预览页面
$('#previewdiv').hide();

$(".userde").click(function(){
	$("#userdetils").toggle(300);
	setTimeout(function(){
		$("#userdetils").hide(300);
	},5000);

})
$(".navli").click(function(){
	$(this).addClass(' select').siblings().removeClass(' select');					
});
$("#nav01").click(function(){
	window.location.href="index.html"; 
	// window.location.replace();
});
//操作员管理
$("#nav02").click(function(){
	$("#rightcontent").load("operatorManagement.html");
});
//菜单管理
$("#nav03").click(function(){
	$("#rightcontent").load("404.html");
});
//用户管理
$("#nav04").click(function(){
	$("#rightcontent").load("userManagement.html");
});
$("#nav05").click(function(){
	$("#rightcontent").load("404.html");
});
//角色管理
// $("#nav06").click(function(){
// 	$("#rightcontent").load("roleManagement.html");
// });
//内容管理
$("#nav07").click(function(){
	window.location.href="contentManagement.html"; 
	// $("#rightcontent").load("contentManagement.html");
});

$("#nav08").click(function(){
	$("#rightcontent").load("404.html");
});
$("#nav09").click(function(){
	$("#rightcontent").load("404.html");
});
$("#nav10").click(function(){
	$("#rightcontent").load("404.html");
});
$("#nav11").click(function(){
	$("#rightcontent").load("404.html");
});
$("#nav12").click(function(){
	$("#rightcontent").load("404.html");
});

console.log('内容管理');
	$(".conterli").click(function(){
		$(this).addClass('liselect').siblings().removeClass('liselect');					
	});
	// 导航跳转
	$("#audios").click(function(){
		$(".conterdiv").load("contentManagement2.html");
	})
	// $("#tuwen").click(function(){
	// 		$(".conterdiv").load("contentManagement.html .conter");
	// });
	$("#videos").click(function(){
		$(".conterdiv").load("contentManagement3.html");
	});
	$(".addtuwen").click(function(){
		console.log("新建图文");
		window.location.href='addcontent.html';
	})

	var urank = $.session.get('rank');//登录用户的权限等级
	//内容数据
	var newpage = 0; //当前页面
	var id = 0;//序号
	var pagesize = 5; //每页条数
	conteninfo(newpage);//加载数据
	var keywords='';//关键字

	$(".usersear").click(function(){
		 keywords= $('.searchinpu').val();
		search();
	})
	function search() {
		// 搜索内容部分，包括图文，语音，视频
		$.ajax({
					type: "get",
					url: url+"article/findByKeyword",
					data:{
						'page': newpage,
						'pageSize': pagesize,
						'title': keywords
					},
					success: function(data){
						if (data.code=='2000') {
							var ulist = data.data.content;//内容数据
							var pageable = data.data.pageable; //用户翻页
							var totalElements = data.data.totalElements; //总条数
							var pageNumber = pageable.pageNumber;//当前第几页
							var totalPages = data.data.totalPages;//总页数
							console.log(ulist);
							console.log("twnum="+totalElements);
							$(".conleft").html('搜索(共'+totalElements+'条)');
							console.log('加载成功');
							var coninfo = '<div class="tab_title">'
												+'<span class="tabt01">内容</span>'
												+'<span class="tabt02">更新时间</span>'
												+'<span class="tabt03">操作</span>'
											+'</div>'
											+'<div class="tab_content">';
							if(ulist.length == 0){
								coninfo += '没有您要找的数据！';
							}else{							
							for(var i in ulist){
								coninfo += '<div class="tab_li">'
													+'<div class="tabt01" sid='+ulist[i].sid+'>'
														+'<img class="tab_img" src="'+ulist[i].backgroundImage+'">'
														+'<span class="tab_name">'+ulist[i].title+'</span>'
													+'</div>'
													+'<div class="tabt02">'
														+'<span class="gryfont">'+timeStamp2String(ulist[i].createdDatetime)+'</span>'
													+'</div>'
													+'<div class="tabt03">'
														+'<a class="tab_editor" sid="'+ulist[i].sid+'" title="修改"></a><a class="tab_del" sid="'+ulist[i].sid+'" title="删除"></a>'
													+'</div>'
												+'</div>';
							}
							}
							coninfo+='</div>';
							$("#table02").html('');
							$("#table02").append(coninfo);

							//文章预览
							$('.tabt01').click(function(){
								$('#previewdiv').show('fast');
								console.log('123');
								console.log($(this).attr('sid'));
								var thishtml = '';//清空iframe
								var thisid = $(this).attr('sid');
								thishtml = '<iframe src="iframe/wenzde.html?id='+thisid+'"width="375" height="667" scrolling="no" seamless="seamless">			  <p>您的浏览器不支持 iframe 标签。请使用Chrome，Firefox，360等浏览器</p>			</iframe>'
								$('.iframediv').html(thishtml);
							})
							
								  //关闭预览页面
							  $('.guanbi').click(function(){
							  	console.log(123);
							  	console.log($('#previewdiv'));
							  	$('#previewdiv').hide('fast');
							  })

							//翻页
							var pagehtml='';
							var now = pageNumber+1;
							pagehtml = '<a class="pre"><</a>'
									+'<ul class="pagesul">'
										+'<li class="pagesnum thispage">'+now+'</li>'
										+'<li class="pagesnum">总共'+totalPages+'页</li>'
										+'<li class="pagesnum"><input class="pageinp" id="yema" type="number" oninput="checkNum(this.value)" placeholder="输入页码" value=""/></li>'
										+'<li class="pagesnum thispage tiaoz">跳转</li>'
									+'</ul>'
									+'<a class="next">></a>';
							$(".pages").html(pagehtml);

							//跳转页码
							$(".tiaoz").click(function(){
								var thispage = $(".pageinp").val(); //输入跳转的页码
								// newpage = parseInt(thispage-1);
								//输入页码不为空
								if(thispage.length!=0 && !isNaN(thispage)){
									console.log("当前输入页面"+thispage);
									if(totalPages+1>thispage>0){
										if(newpage == thispage-1){
											//如果是跳转当前页面,则不跳转，不刷新页面
											console.log('跳转当前页面');
											newpage = thispage-1;
											return false;
										}else{
											//跳转到输入页面
											id = (thispage-1)*pagesize;//跳转页面id起始
											newpage = thispage-1;
											search(newpage);
										}
										
									}else{
										alert('请输入准确页码');
										$(".pageinp").val('');//清空搜索框
									}									
								}								
							});
							//上一页
							$(".pre").click(function(){
								console.log(newpage);
								if(newpage>0){
									//当前页面需要大于0 ，小于总页数
									//如果当前条数少于每页条数时，即最后一页	
									newpage = newpage-1;			
									search(newpage);
								}else{
									alert('没有上一页了');
								}								
							})
							//下一页
							$(".next").click(function(){
								console.log('当前第几页'+newpage);
								if(totalPages-1>newpage){
									//当前页面需要小于总页数
									newpage = newpage+1;
									search(newpage);
								}else{
									alert('没有下一页了');
								}
							})
							
							//编辑修改内容
							$(".tab_editor").click(function(){
								var thisid = $(this).attr("sid");
								window.location.href='editecontent.html?sid='+thisid;
							})

							//删除内容
							$(".tab_del").click(function(){
								var thisid = $(this).attr("sid");
								$.ajax({
									type: "post",
									url: url+"article/DropBySid",
									data:{
										'sid': thisid,
										'rank': urank
									},
									success: function(data){
										if(data.code=='2000'){
											console.log('删除成功');
											search(newpage);//刷新列表数据
										}else if(data.code=='5000'){
											console.log('权限不够');
										}else{
											console.log('系统错误');
										}
									}
								})								
							});

						}
					}
				})
	}

	// 用户数据
	function conteninfo(){
		$.ajax({
					type: "get",
					url: url+"article/showAllByPage",
					data:{
						'page': newpage,
						'pageSize': pagesize,
						'palyType': 3
					},
					success: function(data){
						if (data.code=='2000') {
							var ulist = data.data.all.content;//内容数据
							var pageable = data.data.all.pageable; //用户翻页
							var totalElements = data.data.all.totalElements; //总条数
							var pageNumber = pageable.pageNumber;//当前第几页
							var totalPages = data.data.all.totalPages;//总页数
							console.log(ulist);
							console.log("twnum="+totalElements);
							$(".conleft").html('图文(共'+totalElements+'条)');
							console.log('加载成功');
							var coninfo = '<div class="tab_title">'
												+'<span class="tabt01">内容</span>'
												+'<span class="tabt02">更新时间</span>'
												+'<span class="tabt03">操作</span>'
											+'</div>'
											+'<div class="tab_content">';
							if(ulist.length == 0){
								coninfo += '没有数据';
							}else{							
							for(var i in ulist){
								coninfo += '<div class="tab_li">'
													+'<div class="tabt01" sid='+ulist[i].sid+'>'
														+'<img class="tab_img" src="'+ulist[i].backgroundImage+'">'
														+'<span class="tab_name">'+ulist[i].title+'</span>'
													+'</div>'
													+'<div class="tabt02">'
														+'<span class="gryfont">'+timeStamp2String(ulist[i].createdDatetime)+'</span>'
													+'</div>'
													+'<div class="tabt03">'
														+'<a class="tab_editor" sid="'+ulist[i].sid+'" title="修改"></a><a class="tab_del" sid="'+ulist[i].sid+'" title="删除"></a>'
													+'</div>'
												+'</div>';
							}
							}
							coninfo+='</div>';
							$("#table02").html('');
							$("#table02").append(coninfo);

							//文章预览
							$('.tabt01').click(function(){
								$('#previewdiv').show('fast');
								console.log('123');
								console.log($(this).attr('sid'));
								var thishtml = '';//清空iframe
								var thisid = $(this).attr('sid');
								thishtml = '<iframe src="iframe/wenzde.html?id='+thisid+'"width="375" height="667" scrolling="no" seamless="seamless">			  <p>您的浏览器不支持 iframe 标签。请使用Chrome，Firefox，360等浏览器</p>			</iframe>'
								$('.iframediv').html(thishtml);
							})
							
								  //关闭预览页面
							  $('.guanbi').click(function(){
							  	console.log(123);
							  	console.log($('#previewdiv'));
							  	$('#previewdiv').hide('fast');
							  })

							//翻页
							var pagehtml='';
							var now = pageNumber+1;
							pagehtml = '<a class="pre"><</a>'
									+'<ul class="pagesul">'
										+'<li class="pagesnum thispage">'+now+'</li>'
										+'<li class="pagesnum">总共'+totalPages+'页</li>'
										+'<li class="pagesnum"><input class="pageinp" id="yema" type="number" oninput="checkNum(this.value)" placeholder="输入页码" value=""/></li>'
										+'<li class="pagesnum thispage tiaoz">跳转</li>'
									+'</ul>'
									+'<a class="next">></a>';
							$(".pages").html(pagehtml);

							//跳转页码
							$(".tiaoz").click(function(){
								var thispage = $(".pageinp").val(); //输入跳转的页码
								// newpage = parseInt(thispage-1);
								//输入页码不为空
								if(thispage.length!=0 && !isNaN(thispage)){
									console.log("当前输入页面"+thispage);
									if(totalPages+1>thispage>0){
										if(newpage == thispage-1){
											//如果是跳转当前页面,则不跳转，不刷新页面
											console.log('跳转当前页面');
											newpage = thispage-1;
											return false;
										}else{
											//跳转到输入页面
											id = (thispage-1)*pagesize;//跳转页面id起始
											newpage = thispage-1;
											conteninfo(newpage);
										}
										
									}else{
										alert('请输入准确页码');
										$(".pageinp").val('');//清空搜索框
									}									
								}								
							});
							//上一页
							$(".pre").click(function(){
								console.log(newpage);
								if(newpage>0){
									//当前页面需要大于0 ，小于总页数
									//如果当前条数少于每页条数时，即最后一页	
									newpage = newpage-1;			
									conteninfo(newpage);
								}else{
									alert('没有上一页了');
								}								
							})
							//下一页
							$(".next").click(function(){
								console.log('当前第几页'+newpage);
								if(totalPages-1>newpage){
									//当前页面需要小于总页数
									newpage = newpage+1;
									conteninfo(newpage);
								}else{
									alert('没有下一页了');
								}
							})
							
							//编辑修改内容
							$(".tab_editor").click(function(){
								var thisid = $(this).attr("sid");
								window.location.href='editecontent.html?sid='+thisid;
							})

							//删除内容
							$(".tab_del").click(function(){
								var thisid = $(this).attr("sid");
								$.ajax({
									type: "post",
									url: url+"article/DropBySid",
									data:{
										'sid': thisid,
										'rank': urank
									},
									success: function(data){
										if(data.code=='2000'){
											console.log('删除成功');
											conteninfo(newpage);//刷新列表数据
										}else if(data.code=='5000'){
											console.log('权限不够');
										}else{
											console.log('系统错误');
										}
									}
								})								
							});

						}else{
							console.log('系统错误');
						}
					}
				})
	}

	
</script>
	</body>
	</html>